Skip to content

Conversation

umaannamalai
Copy link
Contributor

@umaannamalai umaannamalai commented Sep 10, 2025

This PR updates Gemini instrumentation and tests to pull token counts directly from the response object. If a customer has an LLM token counting callback function registered, this will still take priority over the response token count values.

It also removes token count calculations from error cases as the agent will consistently stop reporting token counts when a error was met during the creation of a text generation.

@umaannamalai umaannamalai changed the base branch from main to feature-llm-token-counts September 10, 2025 20:56
Copy link

github-actions bot commented Sep 10, 2025

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ ACTION actionlint 7 0 0 0.96s
✅ MARKDOWN markdownlint 7 0 0 0 1.35s
✅ PYTHON ruff 946 0 0 0 1.01s
✅ PYTHON ruff-format 946 0 0 0 0.37s
✅ YAML prettier 15 0 0 0 1.49s
✅ YAML v8r 15 0 0 6.18s
✅ YAML yamllint 15 0 0 0.63s

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security

@mergify mergify bot added the tests-failing Tests failing in CI. label Sep 10, 2025
@codecov-commenter
Copy link

codecov-commenter commented Sep 10, 2025

Codecov Report

❌ Patch coverage is 81.35593% with 88 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.59%. Comparing base (b1408de) to head (ae1aea4).
⚠️ Report is 40 commits behind head on feature-llm-token-counts.

Files with missing lines Patch % Lines
newrelic/hooks/mlmodel_autogen.py 84.96% 15 Missing and 5 partials ⚠️
newrelic/hooks/mlmodel_gemini.py 67.39% 7 Missing and 8 partials ⚠️
newrelic/hooks/external_pyzeebe.py 82.19% 4 Missing and 9 partials ⚠️
newrelic/config.py 72.72% 9 Missing and 3 partials ⚠️
newrelic/core/agent_control_health.py 82.22% 6 Missing and 2 partials ⚠️
newrelic/hooks/mlmodel_openai.py 44.44% 2 Missing and 3 partials ⚠️
newrelic/hooks/framework_webpy.py 0.00% 4 Missing ⚠️
newrelic/core/agent_protocol.py 50.00% 1 Missing and 2 partials ⚠️
newrelic/common/agent_http.py 84.61% 2 Missing ⚠️
newrelic/hooks/adapter_cherrypy.py 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@                     Coverage Diff                      @@
##           feature-llm-token-counts    #1486      +/-   ##
============================================================
+ Coverage                     81.48%   81.59%   +0.11%     
============================================================
  Files                           209      207       -2     
  Lines                         23815    23933     +118     
  Branches                       3753     3793      +40     
============================================================
+ Hits                          19406    19529     +123     
+ Misses                         3153     3127      -26     
- Partials                       1256     1277      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TimPansino TimPansino self-assigned this Sep 15, 2025
@umaannamalai umaannamalai marked this pull request as ready for review October 7, 2025 17:56
@umaannamalai umaannamalai requested a review from a team as a code owner October 7, 2025 17:56
@umaannamalai umaannamalai merged commit 19a7291 into feature-llm-token-counts Oct 7, 2025
92 of 99 checks passed
@umaannamalai umaannamalai deleted the gemini-token-counting branch October 7, 2025 17:57
@mergify mergify bot removed the tests-failing Tests failing in CI. label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants